/*
 * Copyright (c) 2011-2013 www.iflytek.com. All Rights Reserved.
 * This software for customer relationship management system, developed by zy_gczx@iflytek team.
 * Software code and design for the team, copy rights reserved.
 */

// dataTable
$(document).ready(function(){

	//对Tab的处理进行跳转操作，解决默认不进行跳转的事件处理
	$('a[data-toggle="tab"], a[data-toggle="pill"]').on('shown', function () {
		window.location.href = $(this).attr('data-href');
	});

	//绑定表格事件
	$('.data-table').dataTable({
		//显示JqueryUI风格
		"bJQueryUI": true,
		// 是否显示表格的一些信息
		"bInfo": true,
		// 是否启用客户端过滤器
		"bFilter": false,
		// 是否显示每页大小的下拉框
		"bLengthChange": false,
		// 以数字分页控件显示
		"sPaginationType": "full_numbers",
		"sDom": '<""l>t<"F"fp>',
		// 多语音
		"oLanguage": {
			"sProcessing": "正在加载中......",
			"sLengthMenu": "每页显示 _MENU_ 条记录",
			"sZeroRecords": "对不起，查询不到相关数据！",
			"sEmptyTable": "表中无数据存在！",
			"sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
			"sInfoFiltered": "数据表中共为 _MAX_ 条记录",
			"sSearch": "搜索",
			"oPaginate": {
				"sFirst": "首页",
				"sPrevious": "上一页",
				"sNext": "下一页",
				"sLast": "末页"
			}
		}
	});

	//美化表单
	$('input[type=checkbox],input[type=radio],input[type=file]').uniform();

	//下拉组件使用select2组件
	$('select').select2();

	$("span.icon input:checkbox, th input:checkbox").click(function() {
		var checkedStatus = this.checked;
		var checkbox = $(this).parents('.widget-box').find('tr td:first-child input:checkbox');
		checkbox.each(function() {
			this.checked = checkedStatus;
			if (checkedStatus == this.checked) {
				$(this).closest('.checker > span').removeClass('checked');
			}
			if (this.checked) {
				$(this).closest('.checker > span').addClass('checked');
			}
		});
	});
});